/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author itachiu
 */
@Entity
@Table(name = "vacine")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Vacine.findAll", query = "SELECT v FROM Vacine v"),
    @NamedQuery(name = "Vacine.findByIdVACINE", query = "SELECT v FROM Vacine v WHERE v.vacinePK.idVACINE = :idVACINE"),
    @NamedQuery(name = "Vacine.findByName", query = "SELECT v FROM Vacine v WHERE v.name = :name"),
    @NamedQuery(name = "Vacine.findByDossage", query = "SELECT v FROM Vacine v WHERE v.dossage = :dossage"),
    @NamedQuery(name = "Vacine.findByMEDICALRECORDidMEDICALRECORD", query = "SELECT v FROM Vacine v WHERE v.vacinePK.mEDICALRECORDidMEDICALRECORD = :mEDICALRECORDidMEDICALRECORD")})
public class Vacine implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected VacinePK vacinePK;
    @Column(name = "NAME")
    private String name;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "DOSSAGE")
    private Float dossage;
    @JoinColumn(name = "MEDICAL_RECORD_idMEDICAL_RECORD", referencedColumnName = "idMEDICAL_RECORD", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private MedicalRecord medicalRecord;

    public Vacine() {
    }

    public Vacine(VacinePK vacinePK) {
        this.vacinePK = vacinePK;
    }

    public Vacine(int idVACINE, int mEDICALRECORDidMEDICALRECORD) {
        this.vacinePK = new VacinePK(idVACINE, mEDICALRECORDidMEDICALRECORD);
    }

    public VacinePK getVacinePK() {
        return vacinePK;
    }

    public void setVacinePK(VacinePK vacinePK) {
        this.vacinePK = vacinePK;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Float getDossage() {
        return dossage;
    }

    public void setDossage(Float dossage) {
        this.dossage = dossage;
    }

    public MedicalRecord getMedicalRecord() {
        return medicalRecord;
    }

    public void setMedicalRecord(MedicalRecord medicalRecord) {
        this.medicalRecord = medicalRecord;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (vacinePK != null ? vacinePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vacine)) {
            return false;
        }
        Vacine other = (Vacine) object;
        if ((this.vacinePK == null && other.vacinePK != null) || (this.vacinePK != null && !this.vacinePK.equals(other.vacinePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Vacine[ vacinePK=" + vacinePK + " ]";
    }
    
}
